﻿@model IEnumerable<ArticleWeb.Models.ArticleFragment>

@{
    ViewBag.Title = "片段管理";
}
<table class="layui-table">
    <thead>
        <tr>
            <th>内容</th>
            <th>长度</th>
            <th>标签</th>
            <th>引用数</th>
            <th>分类</th>
            <th>状态</th>
            <th>编辑</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
    </thead>

    @foreach (var item in Model)
    {
        <tr>
            <td title="@item.Content">
                <div style="text-overflow:ellipsis;width:600px;white-space:nowrap;overflow:hidden;">@Html.DisplayFor(modelItem => item.Content)</div>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Length)
            </td>
            <td>
                @if (ViewBag.Tags.ContainsKey(item.TagID))
                {
                    @ViewBag.Tags[item.TagID].Name;
                }
                else
                {
                    @Html.DisplayFor(modelItem => item.TagID)
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Referenced)
            </td>
            <td>
                @if (ViewBag.Catagories.ContainsKey(item.CategoryID))
                {
                    @ViewBag.Catagories[item.CategoryID].Name;
                }
                else
                {
                    @Html.DisplayFor(modelItem => item.CategoryID)
                }
            </td>
            <td>
                @if (item.AuditState == ArticleWeb.Models.ArticleAuditState.已审核)
                {
                    <span style="background-color:#5FB878;padding:3px;color:white">已审核</span>
                }
                else
                {
                    @Html.DisplayFor(modelItem => item.AuditState)
                }
            </td>
            <td>
                @if (ViewBag.Users.ContainsKey(item.EditorID.ToString()))
                {
                    @ViewBag.Users[item.EditorID.ToString()].Name;
                }
                else
                {
                    @Html.DisplayFor(modelItem => item.EditorID)
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UpdateTime)
            </td>
            <td>
                @Html.ActionLink("审核", "Audit", new { id = item.ID })
                @Html.ActionLink("编辑", "Edit", new { id = item.ID })
                @Html.ActionLink("删除", "Delete", new { id = item.ID },new { @class="del-btn"})
            </td>
        </tr>
    }
</table>
@using Webdiyer.WebControls.Mvc;
@Html.Pager(new PagedList<ArticleWeb.Models.ArticleFragment>(Model, Request.GetPageIndex(), Request.GetPageSize(), ViewBag.Total), new PagerOptions
{
    PageIndexParameterName = "page",
    CurrentPagerItemWrapperFormatString = "<span class=\"layui-laypage-curr\"><em class=\"layui-laypage-em\"></em><em>{0}</em></span>",
}, new { @class = "layui-box layui-laypage layui-laypage-default" })
